﻿<UserControl x:Class="WickedFlame.VecDraw.Views.PluginPanelView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             x:Name="This"
             xmlns:c="clr-namespace:WickedFlame.VecDraw.Base.Controls;assembly=VecDraw.Base"
             xmlns:vc="clr-namespace:WickedFlame.VecDraw.Plugins"
             xmlns:t="clr-namespace:WickedFlame.Core.Tools;assembly=VecDraw.Core"
             xmlns:local="clr-namespace:WickedFlame.VecDraw.Views" Foreground="WhiteSmoke" FontSize="10">
    
    <UserControl.Resources>

        <Style TargetType="{x:Type Button}" x:Key="transparentButton">
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Border BorderThickness="0" Background="Transparent">
                                <ContentPresenter VerticalAlignment="{TemplateBinding VerticalAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
											SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type local:PluginPanelView}">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:PluginPanelView}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>

                            <Border Name="Border" BorderBrush="#777" BorderThickness="0,1,0,0" CornerRadius="0,4,0,0" VerticalAlignment="Top" Height="25">
                                <Border.Background>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientStop Offset="0.0" Color="#505050" />
                                        <GradientStop Offset="1.0" Color="#282828" />
                                    </LinearGradientBrush>
                                </Border.Background>

                                <Grid>
                                    <Button HorizontalAlignment="Right" Width="20" Height="20" Command="local:PluginPanelView.ExpandCommand" Style="{StaticResource transparentButton}"/>
                                    <Path Grid.Column="3" SnapsToDevicePixels="True" IsHitTestVisible="False" Name="Arrow" Margin="8,0,8,0" Fill="#0FFF" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Right" VerticalAlignment="Center" Data="M 0 0 L 0 8 L 5 4 Z" Stroke="WhiteSmoke" StrokeThickness="0.5">
                                        <Path.RenderTransform>
                                            <RotateTransform Angle="0" />
                                        </Path.RenderTransform>
                                    </Path>
                                </Grid>                                
                            </Border>

                            <c:Reveal x:Name="ContentReveal" Grid.Row="1" VerticalAlignment="Top" VerticalReveal="None" HorizontalReveal="FromRightToLeft">
                                <ContentPresenter VerticalAlignment="Top" />
                            </c:Reveal>
                        </Grid>
                        
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="true">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="0:0:0.2" Storyboard.TargetName="ContentReveal" Storyboard.TargetProperty="AnimationProgress" Duration="0:0:0.2" To="1" DecelerationRatio="1" />
                                            <DoubleAnimation Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" To="180" DecelerationRatio="1" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="ContentReveal" Storyboard.TargetProperty="AnimationProgress" Duration="0:0:0.2" AccelerationRatio="1" />
                                            <DoubleAnimation  Storyboard.TargetName="Arrow" Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)" Duration="0:0:0.2" AccelerationRatio="1" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
    </UserControl.Resources>

    <Grid>
        <StackPanel Name="contentPanel" Grid.Row="1" Orientation="Vertical" VerticalAlignment="Stretch">
            <vc:Tools DrawingCanvas="{Binding .}" />
            <vc:MainColorSelector DrawingCanvas="{Binding .}" FillBrush="{Binding Source={x:Static t:ShapePropertySettings.Settings}, Path=Fill}" StrokeBrush="{Binding Source={x:Static t:ShapePropertySettings.Settings}, Path=Stroke}" />
            <vc:LayerDisplay DrawingCanvas="{Binding .}" />
            <vc:HistoryViewer DrawingCanvas="{Binding .}" />
            <vc:AboutDisplay />
        </StackPanel>
    </Grid>
    
</UserControl>
